﻿using System.Reflection;

namespace Creventive.Wpf.ShellFactory.Modules
{
    /// <summary>
    ///   Represents a staticly loaded module.
    /// </summary>
    public class StaticModuleInfo : ModuleInfo
    {
        private ApplicationModule applicationModule;

        /// <summary>
        ///   Initializes a new instance of the <see cref = "StaticModuleInfo" /> class.
        /// </summary>
        /// <param name = "assemblyName">Name of the assembly.</param>
        public StaticModuleInfo(AssemblyName assemblyName)
            : base(assemblyName)
        {
            this.OnBeforeLoaded(this.applicationModule);
        }

        /// <summary>
        ///   Gets the application module object. This property may be null.
        /// </summary>
        /// <value>The application module.</value>
        public override ApplicationModule ApplicationModule
        {
            get { return this.applicationModule; }
        }

        /// <summary>
        ///   Gets the type of the module.
        /// </summary>
        /// <value>The type of the module.</value>
        public override sealed ModuleType ModuleType
        {
            get { return ModuleType.Static; }
        }

        /// <summary>
        ///   Called right before the module has been loaded. It is the responsibility of this method to call the OnLoaded method when done.
        /// </summary>
        /// <param name = "applicationModule">The application module.</param>
        protected internal override sealed void OnBeforeLoaded(ApplicationModule applicationModule)
        {
            this.applicationModule = applicationModule;
            this.OnLoaded();
        }
    }
}